﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO;
using DAL;

namespace BLL
{
    public  class IBDetailFunc
    {
        UpdateData updata = new UpdateData();

        public List<IBDetailEntity> LoadAllIBDetail()
        {
            CallMonitorService sv = new CallMonitorService();
            return sv.LoadIBDetailByAll();
        }

        public System.Collections.ArrayList LoadIBDetailByCustomerID(long _customerID)
        {
            CallMonitorService sv = new CallMonitorService();
            var tmp = sv.LoadIBDetailByCustomerID(_customerID);            
            return tmp;
        }

        public CustomerEntity LoadCustomerByPhone(string phone)
        {
            CustomerService sv = new CustomerService();
            CustomerEntity cus = new CustomerEntity();
            if (!string.IsNullOrEmpty(phone))
            {
                if (sv.LoadCustomerByCellPhone(phone) != null)
                {
                    cus = sv.LoadCustomerByCellPhone(phone);
                    return cus;
                }
                else
                {
                    if (sv.LoadCustomerByHomePhone(phone) != null)
                    {
                        cus = sv.LoadCustomerByHomePhone(phone);
                        return cus;
                    }
                    else
                    {
                        if (sv.LoadCustomerByOfficePhone(phone) != null)
                        {
                            cus = sv.LoadCustomerByOfficePhone(phone);
                            return cus;
                        }
                    }
                }
                return null;
            }
            else
            {
                return null;
            }
            
        }

        public void AddIBDetail(IBDetailEntity _ib)
        {
            CallMonitorService sv = new CallMonitorService();
            sv.AddIBDetail(_ib);
        }

        public void UpdateIBDetail(IBDetailEntity _ib)
        {
            CallMonitorService sv = new CallMonitorService();
            sv.UpdateIBDetail(_ib);
        }


       

    }
}
